package com.meilai.project.constant;

import com.meilai.project.controller.mini.dto.MiniSimpleObjForSourceDTO;
import lombok.Getter;

import java.math.BigDecimal;
import java.util.List;
import java.util.SortedMap;
import java.util.TreeMap;
import java.util.stream.Collectors;

/**
 * @author 张驰
 * @description 小程序-过滤筛选-项目入住率
 * @date 2022-08-30 11:10
 */
@Getter
public enum MiniSourceBuildingCheckInRateEnum {
    SEVENTY_TO_EIGHTY(1, "70%-80%", new BigDecimal("0.7"), new BigDecimal("0.8"), 1),
    EIGHTY_TO_NINETY(2, "80%-90%", new BigDecimal("0.8"), new BigDecimal("0.9"), 2),
    NINETY_UP(3, "90%以上", new BigDecimal("0.9"), null, 3);

    private final Integer id;
    private final String name;
    private final BigDecimal min;
    private final BigDecimal max;
    private final Integer sort;

    MiniSourceBuildingCheckInRateEnum(Integer id, String name, BigDecimal min, BigDecimal max, Integer sort) {
        this.id = id;
        this.name = name;
        this.min = min;
        this.max = max;
        this.sort = sort;
    }

    public static List<MiniSimpleObjForSourceDTO> getList(){
        SortedMap<Integer, MiniSourceBuildingCheckInRateEnum> map = new TreeMap<Integer, MiniSourceBuildingCheckInRateEnum>();
        for (MiniSourceBuildingCheckInRateEnum enumObj : MiniSourceBuildingCheckInRateEnum.values()) {
            map.put(enumObj.getSort(), enumObj);
        }
        return map.values().stream().map(d ->
            new MiniSimpleObjForSourceDTO(
                    d.getId().longValue(),
                    d.getName(),
                    MiniSimpleObjForSourceEnum.BUILDING_CHECKIN_RATE.getId(),
                    d.getMin(),
                    d.getMax()
            )
        ).collect(Collectors.toList());
    }
}
